package gameFrame;

import java.awt.*;

//游戏物体的棂类
public class GameObject02 {
    Image img;//对应的图片
    int x,y;//会标
    int speed;//物体移动速度
    int width,height;//物体的宽高


    //定义好了，画自己
    public void drawMySelf(Graphics g){
        g.drawImage(img,x,y,width,height,null);

    }
    //返回该体对应的矩形
    public Rectangle getRec(){
        return new Rectangle(x,y,width,height);
    }
    public GameObject02(){}

    public GameObject02(Image img, int x, int y, int speed, int width, int height) {
        this.img = img;
        this.x = x;
        this.y = y;
        this.speed = speed;
        this.width = width;
        this.height = height;
    }

    public GameObject02(Image img, int x, int y, int speed) {
        this(img,x,y);

        this.speed = speed;
        //当不传宽高是，图片不是空，宽高就是图片的宽高
    }

    public GameObject02(Image img) {
        this.img = img;
        if(this.img!=null){
            this.height = img.getHeight(null);
            this.width = img.getWidth(null);
        }
    }

    public GameObject02(Image img, int x, int y) {
        this(img);
        this.x = x;
        this.y = y;
    }
}

